#!/usr/bin/env ruby
require "rubygems"
require "active_support"

sleep(10)

file=File.open("database","r")
file.each do |bday|
bday=bday.chomp!

bday=bday.split(/,/)
name=bday[0].to_s
dob=bday[1].to_s
image_path=bday[2].to_s

if image_path=="default" then
image_path="~/birthday_remainder/cake.jpeg"
end

dob=dob.split(/-/)

current_time=Time.now
month=current_time.month.to_s
day=current_time.day.to_s

if month.to_i <10 then
month="0"+month
end


tomorrow=1.day.from_now.to_s
tomorrow=tomorrow.split(/ /)
p tomorrow

if dob[1]==month then
	if dob[0]==day  then
		system("notify-send 'BirthDay Remainder'   'Today #{name}  Birthday'   -i #{image_path} -t 3000")

sleep(10)
		system("notify-send 'BirthDay Remainder'   'Did U wished #{name}  Birthday ?'    -t 0")

	end

	if dob[0]==(tomorrow[2])  then
		system("notify-send 'BirthDay Remainder'   'Tomorrow #{name}   Birthday'   -i #{image_path} -t 3000")

sleep(10)
		system("notify-send 'BirthDay Remainder'   'Did U Purchased Gift For #{name}  Birthday ?'    -t 0")

	end
end


mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]

today=Time.now.to_s
today=today.split(/ /)
today[1].to_s

x=mon.index(today[1]).to_i
y=mon.index(tomorrow[1]).to_i



	if (x+1==y or tomorrow[1]=="Jan" ) and dob[0]=="01"  then
		system("notify-send 'BirthDay Remainder'   'Tomorrow #{name}   Birthday'   -i #{image_path} -t 3000")

sleep(10)
		system("notify-send 'BirthDay Remainder'   'Did U Purchased Gift For #{name}  Birthday ?'    -t 0")

	end	


end
